<?php


namespace app\admin\model;


use think\Model;

/**
 * Class HtnsBasestationStore
 * @package app\admin\model
 * @desc 海淘女神-基站-门店列表
 */
class HtnsBasestationStore extends Model
{
    protected $connection = 'htns';
    protected $table = 'eb_htns_basestation_store';
    protected $deleteTime = 'delete_time';
    // 类型
    public $type = [
        1 => '自营基站',
        2 => '加盟基站',
    ];

    // 获取有效门店数
    public function getStoreNum($storeId = 0)
    {
        $where['delete_time'] = 0;
        if($storeId){
            $where['id'] = $storeId;
        }
        $res = self::where($where)->count();
        return $res;
    }

    // 门店名称-类型组装
    public function getStoreNameZz($storeId = 0)
    {
        $rest                 = [];
        $where['delete_time'] = 0;
        if($storeId){
            $where['id'] = $storeId;
        }
        $res                  = self::where($where)->order('id desc')->select()->toArray();
        foreach ($res as $k => $v) {
            $storeName = $this->type[$v['type']] . '-' . $v['name'];
            $rest[$v['id']]    = $storeName;
        }
        return $rest;
    }
}